﻿namespace IBTrader.Indicator.Oscillator
{
    using IBTrader.Modules.Read;
    using IBTrader.Charts;

    class ROC : BasePrices
    {
        public ROC(Worker worker, int interval = 12) : base(worker, new ChartArgs { Group = 1 }, interval) { }
        public override void Add(object _, Line line)
        {
            var idx = (Prices.Index + 1) % Prices.Length;
            if (Prices[idx] != 0)  // use only values already filled
                OnHit(line, ((line.Price - Prices[idx]) / Prices[idx]) * 100);
            Prices.Add(line.Price);
        }
    }
}
